# -*- coding: utf-8 -*-
# @Time    : 2019/11/2 15:54
# @Author  : LiHaowen
# @Email   : lihaowen2017@163.com
# @File    : gen_close.py


def gen_func():

    html = yield "http://projectsedu.com"

    # print(html)
    yield 2
    yield 3
    return "b1"


if __name__ == '__main__':
    gen = gen_func()
    print(next(gen))
    gen.close()  # 关闭生成器， 再执行next会抛异常 StopIteration
    next(gen)
    # GeneratorExit是继承自BaseException而非Exception